<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Java Application Servers</title>
<link rel="stylesheet" href="/cfg/format.css" type="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="keywords" content="jee tutorial, Java, Java application servers">
<meta name="description" content="This part of the Java EE 5 tutorials covers Java Application Servers.">
<meta name="language" content="en">
<meta name="author" content="Jan Bodnar">
<meta name="distribution" content="global">

<script type="text/javascript" src="/lib/jquery.js"></script>
<script type="text/javascript" src="/lib/common.js"></script>

</head>

<body>

<div class="container">

<div id="wide_ad" class="ltow">
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* 160x600, August 2011 */
google_ad_slot = "2484182563";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<div class="content">


<a href="/" title="Home">Home</a>&nbsp;
<a href="..">Contents</a>


<h1>Java Application Servers</h1>


<p>
In this part of the Java EE 5 tutorials, we will mention Java Application Servers (AS). 
</p>

<div class="center"> 
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script> 
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script> 
</div> 

<p>
An <b>aplication server</b> is a server side software, that provides the business 
logic for the application. A Java EE AS is a server application that implements 
the Java EE platform APIs and provides the standard Java EE services. Java EE AS 
differs from traditional web server by providing components that handle JSP pages 
and servlets and by working with databases. The main benefit of an application 
server is the ease of application development. 
</p>

<p>
A three tier application consists of these parts:
</p>

<ul>
<li>Front end</li>
<li>Business logic</li>
<li>Back end</li>
</ul>

<p>
The front end is usually a web based GUI. It displays data and provides the 
look and feel for the application. The business logic is the logic of the application. 
In the three tier layered application, the Java EE AS provides 
most of the business logic. The back end is a database and transaction server. 
(wikipedia.com, firstcup, techtarget.com)
</p>

<p>
There are several well known Java EE application servers. 
</p>


<ul>
<li>Tomcat</li>
<li>Glassfish</li>
<li>JBoss</li>
<li>Resin</li>
<li>OC4J</li>
<li>WebLogic</li>
<li>WebSphere</li>
</ul>

<p>
When we installed the Java EE Netbeans pack, we also installed two 
application servers. Tomcat and Glassfish. After trying several AS, 
I chose Resin AS for this tutorial. This application server is very fast and easy to use. 
</p>



<h2>Tomcat</h2>


<p>
Apache Tomcat is an application server that is used in the official Reference
Implementation for the Java Servlet and JavaServer Pages technologies. 
Tomcat is developed by the Apache Software Foundation (ASF). During the installation 
of the Netbeans IDE, we can choose to install Apache Tomcat AS as well. 
It is then integrated in the IDE. 
</p>

<h3>Starting and stopping Tomcat</h3>

<pre class="code">
$ cd apache-tomcat-6.0.14/bin/
$ ./startup.sh
Using CATALINA_BASE:   /home/vronskij/bin/apache-tomcat-6.0.14
Using CATALINA_HOME:   /home/vronskij/bin/apache-tomcat-6.0.14
Using CATALINA_TMPDIR: /home/vronskij/bin/apache-tomcat-6.0.14/temp
Using JRE_HOME:       /home/vronskij/bin/jdk1.6.0_03/
</pre>

<p>
We go to the bin direcory located in the installation direcory of the 
Apache Tomcat AS. To start the server, 
we launch the startup.sh script. 
</p>


<img src="/img/java/jee/tomcat.png" alt="Apache Tomcat AS">
<div class="figure">Figure: Apache Tomcat AS</div>


<p>
Tomcat listens on the 8080 port by default.
</p>

<pre class="code">
$ ./shutdown.sh
Using CATALINA_BASE:   /home/vronskij/bin/apache-tomcat-6.0.14
Using CATALINA_HOME:   /home/vronskij/bin/apache-tomcat-6.0.14
Using CATALINA_TMPDIR: /home/vronskij/bin/apache-tomcat-6.0.14/temp
Using JRE_HOME:       /home/vronskij/bin/jdk1.6.0_03/
</pre>


<p>
To stop the Apache Tomcat AS, we execute the shutdown.sh script. 
</p>


<h3>Application deployment</h3>

<p>
To deploy a web application, copy the web archive to the <b>webapps</b> 
subdirectory of the apache tomcat installation
directory. 
</p>


<h2>Glassfish</h2>

<p>
Glassfish is a free and open sourced Java Application server for the Java EE 5. 
The source code has been donated by
Sun Microsystems from it's commercial Java System Application Server. 
It is now endorsed by the Sun Corporation and the
Netbeans project. Glassfish can be controlled from the Netbeans IDE.
</p>

<p>
We can install Glassfish, when we install Netbeans Java EE pack. 
</p>

<h3>Starting and stopping Glassfish</h3>

<pre class="code">
$ ./asadmin start-domain domain1
</pre>

<p>
We start the Glassfish server with the <b>asadmin</b> tool. It is located in the bin 
subdirectory of the Glassfish installation directory.
</p>

<img src="/img/java/jee/sunserver.png" alt="Glassfish">
<div class="figure">Figure: Glassfish AS</div>


<p>
Glassfish listens on the 8080 port by default.
</p>

<pre class="code">
$ ./asadmin stop-domain domain1
</pre>

<p>
Here we show, how we stop the Glassfish server.
</p>

<h3>Web application deployment</h3>

<p>
We can deploy the web application by copying the web archive to the 
autodeploy subdirectory. 
</p>

<pre class="code">
$ asadmin deploy --user=admin ~/programming/jee/form/form.war
</pre>

<p>
This is an alternative method of deployment. Here we must also provide a 
password for user admin. The default password is adminadmin. 
</p>


<h2>Resin</h2>

<p>
Resin is high-performance, open source Java EE Applicaiton Server. Resin is 
created by the Caucho Technology Corporation. The Resin is the AS used in 
this tutorial. I found Resin to be the fastest AS. 
</p>

<h3>Installation</h3>

<p>
Installation of Resin AS might be complicated. But for educational purposes, 
we do not need any compilation or advanced configuring. If we want to use Resin 
as a standalone server, the installation process is pretty easy.
We download Resin from <a href="http://www.caucho.com/download">www.caucho.com/download</a>. 
Unpack it to the install dir. 
</p>


<h3>Starting and stopping Resin</h3>

<pre class="code">
$ ./httpd.sh start
Resin/3.1.3 started -server ''.
</pre>


<p>
We go the the bin subdirectory of the Resin installation directory and 
launch the <b>httpd.sh</b> script with the start parameter.
</p>

<img src="/img/java/jee/resin.png" alt="Resin">
<div class="figure">Figure: Resin AS</div>


<p>
The Resin Application Server listens on the 8080 port as well.  
</p>

<pre class="code">
$ ./httpd.sh stop
Resin/3.1.3 stopped -server ''.
</pre>

<p>
This is how we stop the Resin. 
</p>

<h3>Application deployment</h3>

<p>
The deployment is very easy. We just copy the web archive to the <b>webapps</b> subdirectory. 
</p>



<p>
In this part of the JEE tutorial, we have briefly mentioned Java application
servers.
</p>

<div class="center"> 
<script type="text/javascript"><!--
google_ad_client = "pub-9706709751191532";
/* horizontal */
google_ad_slot = "1734478269";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script> 
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script> 
</div> 
<br> 


<div class="botNav, center">
<span class="botNavItem"><a href="/">Home</a></span> ‡ <span class="botNavItem"><a href="..">Contents</a></span> ‡ 
<span class="botNavItem"><a href="#">Top of Page</a></span>
</div>


<div class="footer">
<div class="signature">
<a href="/">ZetCode</a> last modified January 13, 2008  <span class="copyright">&copy; 2007 - 2013 Jan Bodnar</span>
</div>
</div>

</div> <!-- content -->

</div> <!-- container -->

</body>
</html>


